<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div{
        width: 500bbpx;
        height: 700px;
    }
</style>
<body>
    <div>
        <img src="apic27858.jpg" style="height: 700px; width: 500px;">
    </div>
    <script>
        
        var img = document.getElementsByTagName('img')[0];
        const imgArr = ['apic27858.jpg', 'v2-58d652598269710fa67ec8d1c88d8f03_r.jpg', 'OIP-C11.jpg'];
        var count = 0;

        //只执行一次
        function fn() {
            if(count<2){
                count++;
            }else{
                count = 0;
            }
            
            img.src =  imgArr[count]
            //n! 递归(调用函数本身): 出口， 表达式
            return setTimeout(fn, 3000);
        }
        setTimeout(fn, 3000);
    </script>
</body>
</html>